package com.hb.common.controller;

import com.hb.common.dto.DbBackupTask;
import com.hb.common.service.DbBackupTaskService;
import com.hb.common.util.Result;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 备份任务
 */
@RestController
public class DbBackupTaskController {

    @Resource
    private DbBackupTaskService dbBackupTaskService;

    /**
     * 保存备份任务
     */
    @PostMapping("/db-backup/task")
    public Result<Boolean> save(@RequestBody DbBackupTask backupTask) {
        return dbBackupTaskService.insertOrUpdate(backupTask);
    }

    /**
     * 根据id获取备份任务
     */
    @GetMapping("/db-backup/task/{id}")
    public Result<DbBackupTask> getById(@PathVariable Integer id) {
        return dbBackupTaskService.selectById(id);
    }

    /**
     * 删除备份任务
     */
    @DeleteMapping("/db-backup/task")
    public Result<Boolean> delete(@RequestBody List<Integer> ids) {
        return dbBackupTaskService.delete(ids);
    }

}
